# -*- coding:utf8 -*-

import pickle

from ADN import ADN
from Allele import Allele
from Gene import Gene

def initADN(score):
    """function initADN

    returns ADN
    """
    adn = ADN()

    ethnics = Gene('ethnics')
    africa1_0 = Allele((('africa-aethiopid', 'EthnicName'), (0, 'EthnicVal')), 'a-eth-0')
    africa1_1 = Allele((('africa-aethiopid', 'EthnicName'), (0.5, 'EthnicVal')), 'a-eth-05')
    africa1_2 = Allele((('africa-aethiopid', 'EthnicName'), (1, 'EthnicVal')), 'a-eth-1')
    africa2_0 = Allele((('africa-central', 'EthnicName'), (0, 'EthnicVal')), 'a-cen-0')
    africa2_1 = Allele((('africa-central', 'EthnicName'), (0.5, 'EthnicVal')), 'a-cen-05')
    africa2_2 = Allele((('africa-central', 'EthnicName'), (1, 'EthnicVal')), 'a-cen-1')
    africa3_0 = Allele((('africa-khoisan', 'EthnicName'), (0, 'EthnicVal')), 'a-koi-0')
    africa3_1 = Allele((('africa-khoisan', 'EthnicName'), (0.5, 'EthnicVal')), 'a-koi-05')
    africa3_2 = Allele((('africa-khoisan', 'EthnicName'), (1, 'EthnicVal')), 'a-koi-1')
    africa4_0 = Allele((('africa-nilotid', 'EthnicName'), (0, 'EthnicVal')), 'a-nil-0')
    africa4_1 = Allele((('africa-nilotid', 'EthnicName'), (0.5, 'EthnicVal')), 'a-nil-05')
    africa4_2 = Allele((('africa-nilotid', 'EthnicName'), (1, 'EthnicVal')), 'a-nil-1')
    africa5_0 = Allele((('africa-pigmy', 'EthnicName'), (0, 'EthnicVal')), 'a-pig-0')
    africa5_1 = Allele((('africa-pigmy', 'EthnicName'), (0.5, 'EthnicVal')), 'a-pig-05')
    africa5_2 = Allele((('africa-pigmy', 'EthnicName'), (1, 'EthnicVal')), 'a-pig-1')
    africa6_0 = Allele((('africa-sudanid', 'EthnicName'), (0, 'EthnicVal')), 'a-suda-0')
    africa6_1 = Allele((('africa-sudanid', 'EthnicName'), (0.5, 'EthnicVal')), 'a-suda-05')
    africa6_2 = Allele((('africa-sudanid', 'EthnicName'), (1, 'EthnicVal')), 'a-suda-1')
    asia1_0 = Allele((('asia-northindian', 'EthnicName'), (0, 'EthnicVal')), 'as-north-0')
    asia1_1 = Allele((('asia-northindian', 'EthnicName'), (0.5, 'EthnicVal')), 'as-north-05')
    asia1_2 = Allele((('asia-northindian', 'EthnicName'), (1, 'EthnicVal')), 'as-north-1')
    asia2_0 = Allele((('asia-southindian', 'EthnicName'), (0, 'EthnicVal')), 'as-sou-0')
    asia2_1 = Allele((('asia-southindian', 'EthnicName'), (0.5, 'EthnicVal')), 'as-sou-05')
    asia2_2 = Allele((('asia-southindian', 'EthnicName'), (1, 'EthnicVal')), 'as-sou-1')
    nordid_0 = Allele((('europe-nordid', 'EthnicName'), (0, 'EthnicVal')), 'eu-nord-0')
    nordid_1 = Allele((('europe-nordid', 'EthnicName'), (0.5, 'EthnicVal')), 'eu-nord-05')
    nordid_2 = Allele((('europe-nordid', 'EthnicName'), (1, 'EthnicVal')), 'eu-nord-1')
    neutralf_0 = Allele((('neutral-female', 'EthnicName'), (0, 'EthnicVal')), 'neu-fem-0')
    neutralf_1 = Allele((('neutral-female', 'EthnicName'), (0.5, 'EthnicVal')), 'neu-fem-05')
    neutralf_2 = Allele((('neutral-female', 'EthnicName'), (1)), 'neu-fem-1')
    neutralm_0 = Allele((('neutral-male', 'EthnicName'), (0, 'EthnicVal')), 'neu-mal-0')
    neutralm_1 = Allele((('neutral-male', 'EthnicName'), (0.5, 'EthnicVal')), 'neu-mal-05')
    neutralm_2 = Allele((('neutral-male', 'EthnicName'), (1, 'EthnicVal')), 'neu-mal-1')
    universalf_0 = Allele((('universal-female', 'EthnicName'), (0, 'EthnicVal')), 'univ-fem-0')
    universalf_1 = Allele((('universal-female', 'EthnicName'), (0.5, 'EthnicVal')), 'univ-fem-05')
    universalf_2 = Allele((('universal-female', 'EthnicName'), (1, 'EthnicVal')), 'univ-fem-1')
    universalm_0 = Allele((('universal-male', 'EthnicName'), (0, 'EthnicVal')), 'univ-mal-0')
    universalm_1 = Allele((('universal-male', 'EthnicName'), (0.5, 'EthnicVal')), 'univ-mal-05')
    universalm_2 = Allele((('universal-male', 'EthnicName'), (1, 'EthnicVal')), 'univ-mal-1')
    universals_0 = Allele((('universal-stature', 'EthnicName'), (0, 'EthnicVal')), 'univ-stat-0')
    universals_1 = Allele((('universal-stature', 'EthnicName'), (0.5, 'EthnicVal')), 'univ-stat-05')
    universals_2 = Allele((('universal-stature', 'EthnicName'), (1, 'EthnicVal')), 'univ-stat-1')

    ethnics.ajouterAllele(africa1_0)
    ethnics.ajouterAllele(africa1_1)
    ethnics.ajouterAllele(africa1_2)
    ethnics.ajouterAllele(africa2_0)
    ethnics.ajouterAllele(africa2_1)
    ethnics.ajouterAllele(africa2_2)
    ethnics.ajouterAllele(africa3_0)
    ethnics.ajouterAllele(africa3_1)
    ethnics.ajouterAllele(africa3_2)
    ethnics.ajouterAllele(africa4_0)
    ethnics.ajouterAllele(africa4_1)
    ethnics.ajouterAllele(africa4_2)
    ethnics.ajouterAllele(africa5_0)
    ethnics.ajouterAllele(africa5_1)
    ethnics.ajouterAllele(africa5_2)
    ethnics.ajouterAllele(africa6_0)
    ethnics.ajouterAllele(africa6_1)
    ethnics.ajouterAllele(africa6_2)
    ethnics.ajouterAllele(asia1_0)
    ethnics.ajouterAllele(asia1_1)
    ethnics.ajouterAllele(asia1_2)
    ethnics.ajouterAllele(asia2_0)
    ethnics.ajouterAllele(asia2_1)
    ethnics.ajouterAllele(asia2_2)
    ethnics.ajouterAllele(nordid_0)
    ethnics.ajouterAllele(nordid_1)
    ethnics.ajouterAllele(nordid_2)
    ethnics.ajouterAllele(neutralf_0)
    ethnics.ajouterAllele(neutralf_1)
    ethnics.ajouterAllele(neutralf_2)
    ethnics.ajouterAllele(neutralm_0)
    ethnics.ajouterAllele(neutralm_1)
    ethnics.ajouterAllele(neutralm_2)
    ethnics.ajouterAllele(universalf_0)
    ethnics.ajouterAllele(universalf_1)
    ethnics.ajouterAllele(universalf_2)
    ethnics.ajouterAllele(universalm_0)
    ethnics.ajouterAllele(universalm_1)
    ethnics.ajouterAllele(universalm_2)
    ethnics.ajouterAllele(universals_0)
    ethnics.ajouterAllele(universals_1)
    ethnics.ajouterAllele(universals_2)

    sexe = Gene('sexe')
    h = Allele((1, 'Gender'), 'homme')
    a = Allele((0.5, 'Gender'), 'androgyne')
    f = Allele((0, 'Gender'), 'femme')
    sexe.ajouterAllele(h)
    sexe.ajouterAllele(a)
    sexe.ajouterAllele(f)

    corpulence = Gene('musculature')
    c = Allele((0, 'Muscle'), 'Chétif')
    n = Allele((0.5, 'Muscle'), 'Normal')
    m = Allele((1, 'Muscle'), 'Musclé')
    corpulence.ajouterAllele(c)
    corpulence.ajouterAllele(n)
    corpulence.ajouterAllele(m)

    poids = Gene('poids')
    m = Allele((0, 'Weight'), 'Maigre')
    n = Allele((0.5, 'Weight'), 'Normal')
    g = Allele((1, 'Weight'), 'Gros')
    poids.ajouterAllele(m)
    poids.ajouterAllele(n)
    poids.ajouterAllele(g)

    adn.ajouterGene(ethnics)
    adn.ajouterGene(sexe)
    adn.ajouterGene(corpulence)
    adn.ajouterGene(poids)

    adn.reindex()


    # @type score Score
    score.score(africa1_0.getId(), 0.1, 'courir')
    score.score(africa1_0.getId(), 0.1, 'courir')
    score.score(africa1_1.getId(), 0.1, 'courir')
    score.score(africa1_2.getId(), 0.1, 'courir')
    score.score(africa2_0.getId(), 0.1, 'courir')
    score.score(africa2_1.getId(), 0.1, 'courir')
    score.score(africa2_2.getId(), 0.1, 'courir')
    score.score(africa3_0.getId(), 0.1, 'courir')
    score.score(africa3_1.getId(), 0.1, 'courir')
    score.score(africa3_2.getId(), 0.1, 'courir')
    score.score(africa4_0.getId(), 0.1, 'courir')
    score.score(africa4_1.getId(), 0.1, 'courir')
    score.score(africa4_2.getId(), 0.1, 'courir')
    score.score(africa5_0.getId(), 0.1, 'courir')
    score.score(africa5_1.getId(), 0.1, 'courir')
    score.score(africa5_2.getId(), 0.1, 'courir')
    score.score(africa6_0.getId(), 0.1, 'courir')
    score.score(africa6_1.getId(), 0.1, 'courir')
    score.score(africa6_2.getId(), 0.1, 'courir')
    score.score(asia1_0.getId(), 0.1, 'courir')
    score.score(asia1_1.getId(), 0.1, 'courir')
    score.score(asia1_2.getId(), 0.1, 'courir')
    score.score(asia2_0.getId(), 0.1, 'courir')
    score.score(asia2_1.getId(), 0.1, 'courir')
    score.score(asia2_2.getId(), 0.1, 'courir')
    score.score(nordid_0.getId(), 0.1, 'courir')
    score.score(nordid_1.getId(), 0.1, 'courir')
    score.score(nordid_2.getId(), 0.1, 'courir')
    score.score(neutralf_0.getId(), 0.1, 'courir')
    score.score(neutralf_1.getId(), 0.1, 'courir')
    score.score(neutralf_2.getId(), 0.1, 'courir')
    score.score(neutralm_0.getId(), 0.1, 'courir')
    score.score(neutralm_1.getId(), 0.1, 'courir')
    score.score(neutralm_2.getId(), 0.1, 'courir')
    score.score(universalf_0.getId(), 0.1, 'courir')
    score.score(universalf_1.getId(), 0.1, 'courir')
    score.score(universalf_2.getId(), 0.1, 'courir')
    score.score(universalm_0.getId(), 0.1, 'courir')
    score.score(universalm_1.getId(), 0.1, 'courir')
    score.score(universalm_2.getId(), 0.1, 'courir')
    score.score(universals_0.getId(), 0.1, 'courir')
    score.score(universals_1.getId(), 0.1, 'courir')
    score.score(universals_2.getId(), 0.1, 'courir')

    score.score(h.getId(), 0.5, 'courir')
    score.score(a.getId(), 0.1, 'courir')
    score.score(f.getId(), 0.5, 'courir')

    score.score(c.getId(), 0.1, 'courir')
    score.score(n.getId(), 0.5, 'courir')
    score.score(m.getId(), 0.9, 'courir')

    score.score(m.getId(), 0.2, 'courir')
    score.score(n.getId(), 0.6, 'courir')
    score.score(g.getId(), 0.1, 'courir')

    pickle.dump(adn, open('adn.list', 'w+'))
    pickle.dump(score.getAll(), open('score.list', 'w+'))
    return adn